#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+5,mod=998244353;
bool stt;
int power(int a,int b){int res=1;for(;b;b>>=1){if(b&1)res=1ll*res*a%mod;a=1ll*a*a%mod;}return res;}
int n,k,q,ns[N],p[N],xx[N],yy[N];
struct Mat{int a[3][3];Mat(){memset(a,0,sizeof(a));}}temp;
Mat operator * (Mat a,Mat b){Mat res;for(int i=0;i<3;i++)for(int j=0;j<3;j++)for(int k=0;k<3;k++)res.a[i][j]=(res.a[i][j]+1ll*a.a[i][k]*b.a[k][j])%mod;return res;}
Mat power(Mat a,int b)
{
	Mat res;for(int i=0;i<3;i++)res.a[i][i]=1;
	for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}
	return res;
}
struct Seg_tree
{
	int tot;
	struct STree{int lc,rc,num;}t[N*250];
	void change(int &p,int l,int r,int x,int v)
	{
		if(!p)p=++tot;if(l==r)return t[p].num+=v,void();int mid=l+r>>1;
		if(x<=mid)change(t[p].lc,l,mid,x,v);else change(t[p].rc,mid+1,r,x,v);
		t[p].num=t[t[p].lc].num+t[t[p].rc].num;
	}
	int ask(int &p,int l,int r,int al,int ar)
	{
		if(!t[p].num)return 0;if(al<=l && r<=ar)return t[p].num;
		int mid=l+r>>1,res=0;
		if(al<=mid)res+=ask(t[p].lc,l,mid,al,ar);if(mid<ar)res+=ask(t[p].rc,mid+1,r,al,ar);
		return res;
	}
}t1;
struct BIT
{
	int rt[N];
	int lowbit(int x){return (x&-x);}
	void add(int x,int y,int v){for(int i=x;i<=n;i+=lowbit(i))t1.change(rt[i],1,n,y,v);}
	int ask(int ax,int ay,int by)
	{
		int res=0;
		for(int i=ax;i>=1;i-=lowbit(i))res+=t1.ask(rt[i],1,n,ay,by);
		return res;
	}
}t2;
struct BIT1
{
	int t[N];
	int lowbit(int x){return (x&-x);}
	void add(int x,int v){for(int i=x;i<=n;i+=lowbit(i))t[i]+=v;}
	int ask(int x)
	{
		int res=0;
		for(int i=x;i>=1;i-=lowbit(i))res+=t[i];
		return res;
	}
}t3;
int all1,all2;
int ff[N],gg[N],nnss[N];
int slv(int pos,ll ns,ll nnum)
{
	int ans=0;int all=1ll*n*(n-1)/2%mod;
	int f=ff[pos],g=gg[pos],nss=nnss[pos];
	ns%=mod,nnum%=mod;
	ans=(ans+1ll*(f-g+mod)*(2*nnum-all1+mod))%mod;
	ans=(ans+1ll*nss*(all1-nnum+mod))%mod;
	ans=(ans+1ll*g*(2*ns-all2+mod))%mod;
	ans=1ll*ans*power(power(all,k-pos),mod-2)%mod;
	return ans;
}
bool edd;
int main()
{
	cerr<<((&stt)-(&edd))/1024.0/1024<<"\n";
	freopen("random.in","r",stdin);
	freopen("random.out","w",stdout);
	scanf("%d %d %d",&n,&k,&q);
	int all=1ll*(n-2)*(n-3)/2%mod;
	int nsum=1;ns[0]=1;
	temp.a[0][0]=1ll*n*(n-1)/2%mod,temp.a[0][1]=n-1,temp.a[1][1]=(all-1+mod)%mod,temp.a[2][1]=n-2;
	temp.a[0][2]=n-2,temp.a[1][2]=(all+1)%mod,temp.a[2][2]=(all-1+2ll*n-6+mod)%mod;
	for(int i=0;i<3;i++)temp.a[i][2]=(temp.a[i][2]-temp.a[i][1]+mod)%mod;
	ll ns=0,nnum=0;
	for(int i=1;i<=n;i++)scanf("%d",&p[i]),t2.add(i,p[i],1),ns+=1ll*i*i-1ll*i*p[i];
	for(int i=1;i<=n;i++)
	{
		nnum+=t3.ask(n)-t3.ask(p[i]);
		t3.add(p[i],1);
	}
	all1=1ll*n*(n-1)/2%mod;
	for(int i=1;i<=n;i++)all2=(all2+1ll*i*(2*i-1-n+mod))%mod;
	Mat st;st.a[0][0]=1,st.a[0][1]=1,st.a[0][2]=0;
	st=st*power(temp,k-q);
	nnss[q]=st.a[0][0],ff[q]=st.a[0][1],gg[q]=st.a[0][2];
	//cout<<nnss[q]<<" "<<ff[q]<<" "<<gg[q]<<endl;
	for(int i=q-1;i>=0;i--)
	{
		st=st*temp;
		nnss[i]=st.a[0][0],ff[i]=st.a[0][1],gg[i]=st.a[0][2];
	}
	printf("%d\n",slv(0,ns,nnum));
	for(int i=1;i<=q;i++)
	{
		int x,y;scanf("%d %d",&x,&y);
		if(y-x>1)
		{
			if(p[x]<p[y])
			{
				nnum+=2*(t2.ask(y-1,p[x],p[y])-t2.ask(x,p[x],p[y]))+1;
			}
			else
			{
				nnum-=2*(t2.ask(y-1,p[y],p[x])-t2.ask(x,p[y],p[x]))+1;
			}
		}
		else
		{
			if(p[x]<p[y])nnum++;
			else nnum--;
		}
		ns-=1ll*x*x-1ll*x*p[x]+1ll*y*y-1ll*y*p[y];
		t2.add(x,p[x],-1),t2.add(x,p[y],1),t2.add(y,p[x],1),t2.add(y,p[y],-1);
		swap(p[x],p[y]);
		ns+=1ll*x*x-1ll*x*p[x]+1ll*y*y-1ll*y*p[y];
		//cout<<ns<<" "<<nnum<<endl;
		printf("%d\n",slv(i,ns,nnum));
	}
	return 0;
}